package com.kedsoft.andaily.service.impl;

import com.kedsoft.andaily.entity.Content;
import com.kedsoft.andaily.mapper.ContentMapper;
import com.kedsoft.andaily.service.ContentService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.kedsoft.andaily.vo.Pagination;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LGP
 * @since 2018-11-29
 */
@Service
public class ContentServiceImpl extends ServiceImpl<ContentMapper, Content> implements ContentService {

    @Override
    public Pagination<Content> pageList(Pagination<Content> pagination, Map<String, Object> query) {
        query.put("offset", pagination.offset());
        query.put("limit", pagination.limit());
        query.put("sort", pagination.getSort());
        query.put("order", pagination.getOrder());
        pagination.setItems(baseMapper.list(query));
        pagination.setTotal(baseMapper.count(query));
        return pagination;
    }
}
